import smtplib
from email.mime.text import MIMEText

		
def send_html(sender:str,passward:str,smtp:str,to:str,subject:str,content:str):
	try:
		msg_from = sender
		passward = passward       # 授权码
		msg_to = to  # 接收方
		subject = subject             # 主题
		content = content  # 内容
		msg = MIMEText(content, 'html', 'utf-8')   # html格式
		# msg = MIMEText(content, 'plain', 'utf-8')  # 文本格式
		msg['Subject'] = subject
		msg['From'] = msg_from
		msg['To'] = msg_to
		s = smtplib.SMTP(smtp, 25)
		s.ehlo()
		s.starttls()
		s.login(msg_from, passward)
		s.sendmail(msg_from, msg_to, msg.as_string())
		s.quit()
		return True
	except smtplib.SMTPException as e:
		return False

def send_plain_text(sender:str,passward:str,smtp:str,to:str,subject:str,content:str):
	try:
		msg_from = sender
		passward = passward       # 授权码
		msg_to = to  # 接收方
		subject = subject             # 主题
		content = content  # 内容
		#msg = MIMEText(content, 'html', 'utf-8')   # html格式
		msg = MIMEText(content, 'plain', 'utf-8')  # 文本格式
		msg['Subject'] = subject
		msg['From'] = msg_from
		msg['To'] = msg_to
		s = smtplib.SMTP(smtp, 25)
		s.ehlo()
		s.starttls()
		s.login(msg_from, passward)
		s.sendmail(msg_from, msg_to, msg.as_string())
		s.quit()
		return True
	except smtplib.SMTPException as e:
		return False 

